import { defineStore } from 'pinia';

export const usePaymentStore = defineStore('payment', () => {
	function doWechatPayment(param?: any) {
		// @ts-ignore
		if (typeof WeixinJSBridge !== 'undefined') {
			// @ts-ignore
			WeixinJSBridge.invoke(
				'getBrandWCPayRequest',
				{
					appId: 'wx30c6439b35630874',
					timeStamp: param.timeStamp,
					nonceStr: param.nonceStr,
					package: param.package,
					signType: param.signType,
					paySign: param.paySign
				},
				function (res: any) {
					if (res.err_msg == 'get_brand_wcpay_request:ok') {
						uni.navigateTo({
							url: '/pages/order-list/order-list'
						});
					}
				}
			);
		}
	}

	return {
		doWechatPayment
	};
});
